/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EDataTypeEList;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.example.cr.cR.ArrayElement;
import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.Print;
import org.xtext.example.cr.cR.Variable;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Print</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.PrintImpl#getFunction <em>Function</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.PrintImpl#getVar <em>Var</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.PrintImpl#getMsg <em>Msg</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.PrintImpl#getAeParam <em>Ae Param</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PrintImpl extends MinimalEObjectImpl.Container implements Print
{
  /**
   * The default value of the '{@link #getFunction() <em>Function</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFunction()
   * @generated
   * @ordered
   */
  protected static final String FUNCTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getFunction() <em>Function</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFunction()
   * @generated
   * @ordered
   */
  protected String function = FUNCTION_EDEFAULT;

  /**
   * The cached value of the '{@link #getVar() <em>Var</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVar()
   * @generated
   * @ordered
   */
  protected EList<Variable> var;

  /**
   * The cached value of the '{@link #getMsg() <em>Msg</em>}' attribute list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMsg()
   * @generated
   * @ordered
   */
  protected EList<String> msg;

  /**
   * The cached value of the '{@link #getAeParam() <em>Ae Param</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAeParam()
   * @generated
   * @ordered
   */
  protected EList<ArrayElement> aeParam;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected PrintImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.PRINT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getFunction()
  {
    return function;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFunction(String newFunction)
  {
    String oldFunction = function;
    function = newFunction;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.PRINT__FUNCTION, oldFunction, function));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Variable> getVar()
  {
    if (var == null)
    {
      var = new EObjectResolvingEList<Variable>(Variable.class, this, CRPackage.PRINT__VAR);
    }
    return var;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<String> getMsg()
  {
    if (msg == null)
    {
      msg = new EDataTypeEList<String>(String.class, this, CRPackage.PRINT__MSG);
    }
    return msg;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ArrayElement> getAeParam()
  {
    if (aeParam == null)
    {
      aeParam = new EObjectContainmentEList<ArrayElement>(ArrayElement.class, this, CRPackage.PRINT__AE_PARAM);
    }
    return aeParam;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.PRINT__AE_PARAM:
        return ((InternalEList<?>)getAeParam()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.PRINT__FUNCTION:
        return getFunction();
      case CRPackage.PRINT__VAR:
        return getVar();
      case CRPackage.PRINT__MSG:
        return getMsg();
      case CRPackage.PRINT__AE_PARAM:
        return getAeParam();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.PRINT__FUNCTION:
        setFunction((String)newValue);
        return;
      case CRPackage.PRINT__VAR:
        getVar().clear();
        getVar().addAll((Collection<? extends Variable>)newValue);
        return;
      case CRPackage.PRINT__MSG:
        getMsg().clear();
        getMsg().addAll((Collection<? extends String>)newValue);
        return;
      case CRPackage.PRINT__AE_PARAM:
        getAeParam().clear();
        getAeParam().addAll((Collection<? extends ArrayElement>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.PRINT__FUNCTION:
        setFunction(FUNCTION_EDEFAULT);
        return;
      case CRPackage.PRINT__VAR:
        getVar().clear();
        return;
      case CRPackage.PRINT__MSG:
        getMsg().clear();
        return;
      case CRPackage.PRINT__AE_PARAM:
        getAeParam().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.PRINT__FUNCTION:
        return FUNCTION_EDEFAULT == null ? function != null : !FUNCTION_EDEFAULT.equals(function);
      case CRPackage.PRINT__VAR:
        return var != null && !var.isEmpty();
      case CRPackage.PRINT__MSG:
        return msg != null && !msg.isEmpty();
      case CRPackage.PRINT__AE_PARAM:
        return aeParam != null && !aeParam.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (function: ");
    result.append(function);
    result.append(", msg: ");
    result.append(msg);
    result.append(')');
    return result.toString();
  }

} //PrintImpl
